﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChanPin_PHB.aspx.cs" Inherits="syc.Produce.ChanPin_PHB" %>
<html>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>

    <form id="form1" runat="server">
    <div id="wintop" class="wintop">产品原辅料配合比设置</div>
    <asp:Panel ID="Panel1" runat="server" CssClass="panel">
        <asp:Button ID="Button_New" runat="server" Text="新  增" CssClass="button" 
            UseSubmitBehavior="False" onclick="Button_New_Click" />
    </asp:Panel>
    <asp:Panel ID="Panel2" runat="server" CssClass="panel" Visible="False">
        <table style="width: 100%;font-size:13px;">
            <tr>
                <td width="100" align="right">产品：

                </td>
                <td valign="top">

                    <asp:DropDownList ID="ChanPin" runat="server" Width="200px" 
                        DataSourceID="SqlDataSource2" DataTextField="品名规格" DataValueField="ID">
                    </asp:DropDownList>

                </td>

            </tr>

            <tr>
                <td width="100" style="text-align: right">
                    原辅料：</td>
                <td valign="top">
                    <asp:DropDownList ID="YuanFuLiao" runat="server" Width="200px" 
                        DataSourceID="SqlDataSource3" DataTextField="品名规格" DataValueField="ID">
                    </asp:DropDownList>
                    <asp:RadioButton ID="RadioButton1" runat="server" GroupName="yfl" Text="原料" 
                        AutoPostBack="True" oncheckedchanged="RadioButton1_CheckedChanged" />
                    <asp:RadioButton ID="RadioButton2" runat="server" Checked="True" 
                        GroupName="yfl" Text="辅料" AutoPostBack="True" 
                        oncheckedchanged="RadioButton2_CheckedChanged" />
                </td>
            </tr>

            <tr>
                <td style="text-align: right" width="100">
                    配合比：</td>
                <td valign="top">
                    <asp:TextBox ID="PeiHeBi" runat="server" Width="200px"></asp:TextBox>
                    <asp:Button ID="Button_Save" runat="server" CssClass="button" Text="提 交" 
                        onclick="Button_Save_Click" />
                    <asp:Button ID="Button_Save0" runat="server" CssClass="button" 
                        onclick="Button_Save0_Click" Text="取 消" />
                    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
                        SelectCommand="SELECT [ID], [品名]+' '+ [规格]+'('+[单位]+')' as [品名规格] FROM [产品]"></asp:SqlDataSource>
                    <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
                        SelectCommand="SELECT [ID], [品名]+' '+ [规格]+'('+[单位]+')' as [品名规格] FROM [辅料]"></asp:SqlDataSource>
                </td>
            </tr>

        </table>

    </asp:Panel>

    <asp:Panel ID="Panel3" runat="server" CssClass="panel2" >
        <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt"></asp:Label>
    </asp:Panel>
        
        
    <div class="gridframe">
        <div class="gridview">
        
            <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
	            <tr>
		            <td class="grid-title">产品原辅料配合比</td>
		        </tr>
		        <tr>
		            <td class="grid-back">
                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
                            SelectCommand=
"select [产品原辅料配合比].[id],
[产品].[品名]+' '+[产品].[规格] as [产品及规格],
[产品].[单位] as [产品单位],
[原料].[品名]+' ' +[原料].[规格] as [原辅料],
[原料].[单位] as [原辅料单位],
'原料' as [类别],
[产品原辅料配合比].[配合比]
from [产品原辅料配合比],[产品],[原料]
where [产品].[id]=[产品原辅料配合比].[产品ID]
and [原料].[id]=[产品原辅料配合比].[原辅料ID]
and [产品原辅料配合比].[是原料]=1
union
select [产品原辅料配合比].[id],
[产品].[品名]+' '+[产品].[规格] as [产品及规格],
[产品].[单位] as [产品单位],
[辅料].[品名]+' ' +[辅料].[规格] as [原辅料],
[辅料].[单位] as [原辅料单位],
'辅料' as [类别],
[产品原辅料配合比].[配合比]
from [产品原辅料配合比],[产品],[辅料]
where [产品].[id]=[产品原辅料配合比].[产品ID]
and [辅料].[id]=[产品原辅料配合比].[原辅料ID]
and [产品原辅料配合比].[是原料]=0" 

                            UpdateCommand="update [产品原辅料配合比] set [配合比]=@配合比 where [ID]=@ID"
                            DeleteCommand="delete from [产品原辅料配合比] where [ID]=@ID"
                            ></asp:SqlDataSource>
                        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                            AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID" 
                            DataSourceID="SqlDataSource1" 
                            GridLines="None" ondatabound="GridView1_DataBound" 
                            onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                            UseAccessibleHeader="False">
                            <PagerSettings Visible="False" />
                            <RowStyle CssClass="grid-row-normal" />
                            <Columns>

                                <asp:TemplateField HeaderText="">
                                    <ItemTemplate>
                                        <img src="/Icons/online.gif" style="margin-top:2px;" alt="" />
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="产品及规格" SortExpression="产品及规格">
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("产品及规格") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="150px" />
                                </asp:TemplateField>
                                
                                <asp:TemplateField HeaderText="产品单位" SortExpression="产品单位">
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("产品单位") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                                </asp:TemplateField>
                                
                                <asp:TemplateField HeaderText="原辅料" SortExpression="原辅料">
                                    <ItemTemplate>
                                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("原辅料") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="150px" />
                                </asp:TemplateField>
                                
                                <asp:TemplateField HeaderText="原辅料单位" SortExpression="原辅料单位">
                                    <ItemTemplate>
                                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("原辅料单位") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                                </asp:TemplateField>
                                                                
                                <asp:TemplateField HeaderText="原辅料类别" SortExpression="类别">
                                    <ItemTemplate>
                                        <asp:Label ID="Label5" runat="server" Text='<%# Bind("类别") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="70px" />
                                </asp:TemplateField>
                                
                                
                                <asp:TemplateField HeaderText="配合比" SortExpression="配合比">
                                    <ItemTemplate>
                                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("配合比") %>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("配合比") %>' Width="76"></asp:TextBox>
                                    </EditItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="80px" />
                                </asp:TemplateField>
                                

                                
                                <asp:TemplateField HeaderText="操作" ShowHeader="False" ItemStyle-CssClass="grid"
                                 HeaderStyle-CssClass="grid-header" HeaderStyle-Width="100" ItemStyle-HorizontalAlign="Center">
                                    <ItemTemplate>
                                        <asp:Button ID="Button1" runat="server" CommandName="Edit" Text="配合比" CssClass="smallbutton"/>
                                        <asp:Button ID="Button2" runat="server" CommandName="Delete" Text="删除" CssClass="smallbutton"/>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <asp:Button ID="Button3" runat="server" CommandName="Update" Text="更新" CssClass="smallbutton" UseSubmitBehavior="true"/>
                                        <asp:Button ID="Button4" runat="server" CommandName="Cancel" Text="取消" CssClass="smallbutton"/>
                                    </EditItemTemplate>
                                    
<HeaderStyle CssClass="grid-header" Width="100px"></HeaderStyle>

<ItemStyle HorizontalAlign="Center" CssClass="grid"></ItemStyle>
                                    
                                </asp:TemplateField>
                            </Columns>
                          </asp:GridView>
		            </td>
	            </tr>
	            <tr>
		            <td>   
		                <table width="100%">
		                    <tr>
		                        <td class="pagebar">
                                    <asp:Button ID="Button_Pager_First" runat="server" Text="" ToolTip="首页" 
                                        CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                    <asp:Button ID="Button_Pager_Prev" runat="server" Text="" ToolTip="上一页" 
                                        CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                    <input type="button" class="page-split" />第<asp:TextBox ID="TextBox_Pager" runat="server" CssClass="pageturn" 
                                        ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" /><asp:Label ID="Label_Pages" runat="server"></asp:Label><input type="button" class="page-split" />
                                    
                                    <asp:Button ID="Button_Pager_Next" runat="server" Text="" ToolTip="下一页" 
                                        CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                    <asp:Button ID="Button_Pager_Last" runat="server" Text="" ToolTip="末页" 
                                        CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" />
                                </td>
                                <td align="right">
                                    <asp:Label ID="Label_Total" runat="server" CssClass="grid_totalrows"></asp:Label>
                                </td>
                            </tr>
                       </table>

		            </td>
	            </tr>
            </table>
            

        </div>
    </div>
    
    </form>
<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }

    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
        }
    }
    var tds = document.getElementsByTagName("td");
    for (i = 0; i < tds.length; i++) {
        if (tds[i].className == "detailheader") {
            tds[i].innerHTML = tds[i].innerHTML.replace("*", "<span class=required>*</span>");
        }
    }
</script>
</body>
</html>
